/// <reference path="../../typings/tsd.d.ts" />
/// <reference path="../templates/tmpl.d.ts" />

import * as ko from "knockout";
import * as $ from "jquery";
import * as handlebars from "handlebars";
import * as membertpl from "../templates/member.tpl"
import * as memberhbs from "../templates/member.hbs";

import { baseController } from './interfaceController';
export class detailController implements baseController {
    index() {
        if (window.console && window.console.log) {
            window.console.log('测试detail');
            window.console.log($);
            window.console.log(ko);
            window.console.log(membertpl);
            window.console.log(memberhbs);
            window.console.log(handlebars);
            window.console.log($(memberhbs).find('#entry-template').html())
            var tml = handlebars.compile(memberhbs);
            window.console.log(tml);
            window.console.log(tml({title:'x',body:'y'}));
            window.console.log('end');
        }
        document.getElementById('root').innerHTML = 'this is a detail page.';
        $('#pjax-container>a').pjax();
    }

    detail() {
        class ArrayViewModel {
            items?: any
            content?: any
            constructor(items: Array<number>, content: string) {
                this.items = ko.observableArray(items);
                this.content = ko.observable(content)
            }
        }
        var ele = $('#koId')[0];
        ko.cleanNode(ele);
        ko.applyBindings(new ArrayViewModel([1, 2, 3, 4, 5], 'default-value'), ele);
        $('#koId').show();
    }

    render(s: string) {
        console.log(s);
    }
}